home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / storage / page / block.c next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  1.1 KB  |  57 lines

  1. /*
  2.  * block.c --
  3.  *    POSTGRES disk block code.
  4.  */
  5.  
  6. #include "tmp/c.h"
  7.  
  8. #include "storage/block.h"
  9.  
  10. RcsId("$Header: /private/postgres/src/storage/page/RCS/block.c,v 1.4 1990/09/25 16:45:45 kemnitz Exp $");
  11.  
  12. bool
  13. BlockSizeIsValid(blockSize)
  14.     BlockSize    blockSize;
  15. {
  16.     /* should check that this is a power of 2 */
  17.     return (true);
  18. }
  19.  
  20. bool
  21. BlockNumberIsValid(blockNumber)
  22.     BlockNumber    blockNumber;
  23. {
  24.     return ((bool)(blockNumber >= 0 &&
  25.         (int32)blockNumber != InvalidBlockNumber));
  26. }
  27.  
  28. bool
  29. BlockIdIsValid(blockId)
  30.     BlockId        blockId;
  31. {
  32.     return ((bool)(PointerIsValid(blockId) && blockId->data[0] >= 0));
  33. }
  34.  
  35. void
  36. BlockIdSet(blockId, blockNumber)
  37.     BlockId        blockId;
  38.     BlockNumber    blockNumber;
  39. {
  40.     Assert(PointerIsValid(blockId));
  41. /*    Assert(BlockNumberIsValid(blockNumber));    should check >= 0 */
  42.  
  43.     blockId->data[0] = blockNumber >> 16;
  44.     blockId->data[1] = blockNumber & 0xffff;
  45.     /* *((BlockNumber *)blockId->data) = blockNumber; */
  46. }
  47.  
  48. BlockNumber
  49. BlockIdGetBlockNumber(blockId)
  50.     BlockId    blockId;
  51. {
  52.     Assert(BlockIdIsValid(blockId));
  53.  
  54.     return ((blockId->data[0] << 16) + (uint16)blockId->data[1]);
  55.     /* return (*((BlockNumber *)blockId->data)); */
  56. }
  57.